package com.evildog.workspace.gateway.props;

import lombok.Data;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

/**
 * gateway/应用 不需要检查token的链接
 */
@Data
@ConfigurationProperties(prefix = "workspace.security.ignored")
@ConditionalOnProperty(prefix = "workspace.security.ignored", value = "enable")
@RefreshScope
@Configuration
public class IgnoreUrlsProperties {

    private List<String> skipUrls = new ArrayList<>();

    private static List<String> defaultSkipUrls = new ArrayList<>();

    static {
        defaultSkipUrls.add("/auth/**");
        defaultSkipUrls.add("/file/**");
        defaultSkipUrls.add("/v2/api-docs/**");
        defaultSkipUrls.add("/v2/api-docs-ext/**");

        defaultSkipUrls.add("/**/doc.html");
        defaultSkipUrls.add("/**/swagger-ui.html");
        defaultSkipUrls.add("/**/v2/api-docs");
        defaultSkipUrls.add("/**/swagger-resources/**");
        defaultSkipUrls.add("/**/*.js");
        defaultSkipUrls.add("/**/*.css");
        defaultSkipUrls.add("/**/*.png");
        defaultSkipUrls.add("/**/*.ico");
        defaultSkipUrls.add("/**/swagger/**");
        defaultSkipUrls.add("/**/webjars/springfox-swagger-ui/**");
    }

    /**
     * 默认无需鉴权的API
     */
    public static List<String> getDefaultSkipUrls() {
        return defaultSkipUrls;
    }



}
